From: Ian Jackson Date: Fri, 17 Jan 2014 12:01:24 +0000 (+0000) Subject: libxl: fork: Break out sigchld_installhandler_core X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5608 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=e6a203b4c1475aff200ae7d085ce0fff561daf91;p=xen.git libxl: fork: Break out sigchld_installhandler_core Pure code motion. This is going to make the final substantive patch easier to read. Signed-off-by: Ian Jackson Cc: Jim Fehlig Cc: Ian Campbell Acked-by: Ian Campbell --- diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index a15af8e399..ce8e8ebcf4 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -194,6 +194,27 @@ static void sigchld_removehandler_core(void) sigchld_owner = 0; } +static void sigchld_installhandler_core(libxl__gc *gc) +{ + struct sigaction ours; + int r; + + assert(!sigchld_owner); + sigchld_owner = CTX; + + memset(&ours,0,sizeof(ours)); + ours.sa_handler = sigchld_handler; + sigemptyset(&ours.sa_mask); + ours.sa_flags = SA_NOCLDSTOP | SA_RESTART; + r = sigaction(SIGCHLD, &ours, &sigchld_saved_action); + assert(!r); + + assert(((void)"application must negotiate with libxl about SIGCHLD", + !(sigchld_saved_action.sa_flags & SA_SIGINFO) && + (sigchld_saved_action.sa_handler == SIG_DFL || + sigchld_saved_action.sa_handler == SIG_IGN))); +} + void libxl__sigchld_notneeded(libxl__gc *gc) /* non-reentrant, idempotent */ { int rc; @@ -236,22 +257,7 @@ int libxl__sigchld_needed(libxl__gc *gc) /* non-reentrant, idempotent */ atfork_lock(); if (sigchld_owner != CTX) { - struct sigaction ours; - - assert(!sigchld_owner); - sigchld_owner = CTX; - - memset(&ours,0,sizeof(ours)); - ours.sa_handler = sigchld_handler; - sigemptyset(&ours.sa_mask); - ours.sa_flags = SA_NOCLDSTOP | SA_RESTART; - r = sigaction(SIGCHLD, &ours, &sigchld_saved_action); - assert(!r); - - assert(((void)"application must negotiate with libxl about SIGCHLD", - !(sigchld_saved_action.sa_flags & SA_SIGINFO) && - (sigchld_saved_action.sa_handler == SIG_DFL || - sigchld_saved_action.sa_handler == SIG_IGN))); + sigchld_installhandler_core(gc); } atfork_unlock();